1 % Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite
3 {\ttfamily \raggedright {
5 \mbox{}\textit{\textcolor{Brown
}{//A\ -$>$\ (A)A\ $|$\ Epsilon
}} \\
7 \mbox{}\textbf{\textcolor{RoyalBlue
}{\#include
}}\
\texttt{\textcolor{Red
}{$<$iostream$>$
}} \\
8 \mbox{}\textbf{\textcolor{RoyalBlue
}{\#include
}}\
\texttt{\textcolor{Red
}{$<$string$>$
}} \\
10 \mbox{}\textbf{\textcolor{Blue
}{using
}}\
\textbf{\textcolor{Blue
}{namespace
}}\ std
\textcolor{BrickRed
}{;
} \\
12 \mbox{}\textcolor{ForestGreen
}{bool
}\ ok
\textcolor{BrickRed
}{;
} \\
13 \mbox{}\textcolor{ForestGreen
}{char
}\ sgte
\textcolor{BrickRed
}{;
} \\
14 \mbox{}\textcolor{ForestGreen
}{int
}\ i
\textcolor{BrickRed
}{;
} \\
15 \mbox{}string\ s
\textcolor{BrickRed
}{;
} \\
17 \mbox{}\textcolor{ForestGreen
}{bool
}\
\textbf{\textcolor{Black
}{match
}}\textcolor{BrickRed
}{(
}\textcolor{ForestGreen
}{char
}\ c
\textcolor{BrickRed
}{)
}\textcolor{Red
}{\
{} \\
18 \mbox{}\ \
\textbf{\textcolor{Blue
}{if
}}\
\textcolor{BrickRed
}{(
}sgte\
\textcolor{BrickRed
}{!=
}\ c
\textcolor{BrickRed
}{)
}\textcolor{Red
}{\
{} \\
19 \mbox{}\ \ \ \ ok\
\textcolor{BrickRed
}{=
}\
\textbf{\textcolor{Blue
}{false
}}\textcolor{BrickRed
}{;
} \\
20 \mbox{}\ \
\textcolor{Red
}{\
}} \\
21 \mbox{}\ \ sgte\
\textcolor{BrickRed
}{=
}\ s
\textcolor{BrickRed
}{[++
}i
\textcolor{BrickRed
}{];
} \\
22 \mbox{}\textcolor{Red
}{\
}} \\
24 \mbox{}\textcolor{ForestGreen
}{void
}\
\textbf{\textcolor{Black
}{A
}}\textcolor{BrickRed
}{()
}\textcolor{Red
}{\
{} \\
25 \mbox{}\ \
\textbf{\textcolor{Blue
}{if
}}\
\textcolor{BrickRed
}{(
}sgte\
\textcolor{BrickRed
}{==
}\
\texttt{\textcolor{Red
}{'('
}}\textcolor{BrickRed
}{)
}\textcolor{Red
}{\
{} \\
26 \mbox{}\ \ \ \
\textbf{\textcolor{Black
}{match
}}\textcolor{BrickRed
}{(
}\texttt{\textcolor{Red
}{'('
}}\textcolor{BrickRed
}{);
} \\
27 \mbox{}\ \ \ \
\textbf{\textcolor{Black
}{A
}}\textcolor{BrickRed
}{();
}\
\textbf{\textcolor{Black
}{match
}}\textcolor{BrickRed
}{(
}\texttt{\textcolor{Red
}{')'
}}\textcolor{BrickRed
}{);
}\
\textbf{\textcolor{Black
}{A
}}\textcolor{BrickRed
}{();
} \\
28 \mbox{}\ \
\textcolor{Red
}{\
}}\textbf{\textcolor{Blue
}{else
}}\
\textbf{\textcolor{Blue
}{if
}}\
\textcolor{BrickRed
}{(
}sgte\
\textcolor{BrickRed
}{==
}\
\texttt{\textcolor{Red
}{'\$'
}}\
\textcolor{BrickRed
}{$|$$|$
}\ sgte\
\textcolor{BrickRed
}{==
}\
\texttt{\textcolor{Red
}{')'
}}\textcolor{BrickRed
}{)
}\textcolor{Red
}{\
{} \\
29 \mbox{}\ \ \ \
\textit{\textcolor{Brown
}{//nada
}} \\
30 \mbox{}\ \
\textcolor{Red
}{\
}}\textbf{\textcolor{Blue
}{else
}}\textcolor{Red
}{\
{} \\
31 \mbox{}\ \ \ \ ok\
\textcolor{BrickRed
}{=
}\
\textbf{\textcolor{Blue
}{false
}}\textcolor{BrickRed
}{;
} \\
32 \mbox{}\ \
\textcolor{Red
}{\
}} \\
33 \mbox{}\textcolor{Red
}{\
}} \\
35 \mbox{}\textcolor{ForestGreen
}{int
}\
\textbf{\textcolor{Black
}{main
}}\textcolor{BrickRed
}{()
}\textcolor{Red
}{\
{} \\
36 \mbox{}\ \
\textbf{\textcolor{Blue
}{while
}}\textcolor{BrickRed
}{(
}\textbf{\textcolor{Black
}{getline
}}\textcolor{BrickRed
}{(
}cin
\textcolor{BrickRed
}{,
}\ s
\textcolor{BrickRed
}{)
}\
\textcolor{BrickRed
}{\&\&
}\ s\
\textcolor{BrickRed
}{!=
}\
\texttt{\textcolor{Red
}{"
{}"
{}}}\textcolor{BrickRed
}{)
}\textcolor{Red
}{\
{} \\
37 \mbox{}\ \ \ \ ok\
\textcolor{BrickRed
}{=
}\
\textbf{\textcolor{Blue
}{true
}}\textcolor{BrickRed
}{;
} \\
38 \mbox{}\ \ \ \ s\
\textcolor{BrickRed
}{+=
}\
\texttt{\textcolor{Red
}{'\$'
}}\textcolor{BrickRed
}{;
} \\
39 \mbox{}\ \ \ \ sgte\
\textcolor{BrickRed
}{=
}\ s
\textcolor{BrickRed
}{[(
}i\
\textcolor{BrickRed
}{=
}\
\textcolor{Purple
}{0}\textcolor{BrickRed
}{)
];
} \\
40 \mbox{}\ \ \ \
\textbf{\textcolor{Black
}{A
}}\textcolor{BrickRed
}{();
} \\
41 \mbox{}\ \ \ \
\textbf{\textcolor{Blue
}{if
}}\
\textcolor{BrickRed
}{(
}i\
\textcolor{BrickRed
}{$<$
}\ s
\textcolor{BrickRed
}{.
}\textbf{\textcolor{Black
}{length
}}\textcolor{BrickRed
}{()-
}\textcolor{Purple
}{1}\textcolor{BrickRed
}{)
}\ ok\
\textcolor{BrickRed
}{=
}\
\textbf{\textcolor{Blue
}{false
}}\textcolor{BrickRed
}{;
}\
\textit{\textcolor{Brown
}{//No\ consumi\ toda\ la\ cadena
}} \\
42 \mbox{}\ \ \ \
\textbf{\textcolor{Blue
}{if
}}\
\textcolor{BrickRed
}{(
}ok
\textcolor{BrickRed
}{)
}\textcolor{Red
}{\
{} \\
43 \mbox{}\ \ \ \ \ \ cout\
\textcolor{BrickRed
}{$<$$<$
}\
\texttt{\textcolor{Red
}{"
{}Accepted
}}\texttt{\textcolor{CarnationPink
}{\textbackslash{}n
}}\texttt{\textcolor{Red
}{"
{}}}\textcolor{BrickRed
}{;
} \\
44 \mbox{}\ \ \ \
\textcolor{Red
}{\
}}\textbf{\textcolor{Blue
}{else
}}\textcolor{Red
}{\
{} \\
45 \mbox{}\ \ \ \ \ \ cout\
\textcolor{BrickRed
}{$<$$<$
}\
\texttt{\textcolor{Red
}{"
{}Not\ accepted
}}\texttt{\textcolor{CarnationPink
}{\textbackslash{}n
}}\texttt{\textcolor{Red
}{"
{}}}\textcolor{BrickRed
}{;
} \\
46 \mbox{}\ \ \ \
\textcolor{Red
}{\
}} \\
48 \mbox{}\ \
\textcolor{Red
}{\
}} \\
49 \mbox{}\textcolor{Red
}{\
}} \\
51 } \normalfont\normalsize